home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctj8504.arc / GRAPH16.BAS < prev    next >
BASIC Source File  |  1986-09-14  |  2KB  |  54 lines

  1.  1 '-- GRAPH16.BAS  16-Color Graphics Example
  2.  2 '
  3.  3 '   This program is very slow, even when compiled.
  4.  4 '   It is intended as an example only.
  5.  5 '   The EGA must be the currently active display adapter.
  6. 20 '
  7. 25 '   Runs in Mode E (640 by 200, 16 colors)
  8. 30 '   Memory Map:  4 Planes at &HA000
  9. 40 '   8 Pixels per byte, non-interleaved
  10. 50 '
  11. 60 DEFINT A-Z
  12. 70 CLS
  13. 75 '-- The following line is for the compiled version only.
  14. 80 CALL SETMODE     '-- Set Mode after BASIC initialization
  15. 100 DEF SEG=&HA000 '-- Video buffer
  16. 110 INPUT "How many boxes? ", NBOXES
  17. 200 FOR BOX=1 TO NBOXES
  18. 210    X1=RND*639: Y1=RND*199
  19. 220    X2=RND*639: Y2=RND*199
  20. 230    C=RND*15
  21. 240    GOSUB 900
  22. 250 NEXT BOX
  23. 260 BEEP
  24. 270 WHILE INKEY$="": WEND
  25. 280 SYSTEM
  26. 900 '----------
  27. 901 ' Fill Box from (x1,y1)-(x2,y2) in color C
  28. 910 FOR X=X1 TO X2
  29. 920   FOR Y=Y1 TO Y2
  30. 930     GOSUB 1000
  31. 940   NEXT Y
  32. 950 NEXT X
  33. 960 RETURN
  34. 1000 '----------
  35. 1001 '-- Put Pixel (color=C) at Location (X,Y)
  36. 1010 ROWBYTE = INT (X/8)
  37. 1020 BITMASK = 2 ^ (7 - (X MOD 8) )
  38. 1030 BYTEOFFSET = (Y * 80) + ROWBYTE
  39. 1040 ' Mask all but desired pixel position
  40. 1050 OUT &H3CE,8        '-- Graphics Bit Mask Register
  41. 1060 OUT &H3CF,BITMASK  '-- Mask all but desired pixel
  42. 1070 ' Read previous contents to latches (all maps)
  43. 1080 OUT &H3C4,2        '-- Sequencer Map Mask
  44. 1090 OUT &H3C5,&HFF     '-- Enable all 4 maps
  45. 1100 JUNK = PEEK (BYTEOFFSET)
  46. 1110 ' Blank the pixel
  47. 1120 POKE BYTEOFFSET,0
  48. 1130 ' Now set desired color in sequencer map mask
  49. 1140 OUT &H3C4,2        '-- Sequencer Map Mask
  50. 1150 OUT &H3C5,C        '-- Desired Color
  51. 1160 ' Write 1's to selected planes
  52. 1170 POKE BYTEOFFSET,&HFF
  53. 1180 RETURN
  54.